package dfsketches.gr3d;

public class CameraAnimation {
	public CameraAnimation(Spline spl) {
		spline = spl;
		speed = 0;
		start(0);
	}
	
	public CameraAnimation(CameraAnimation anim) {
		prevMillis = anim.prevMillis;
		speed = anim.speed;
		lastTime = anim.lastTime;
		spline = anim.spline;
	}

	public void start(float animSpeed) {
		prevMillis = System.currentTimeMillis();
		speed = animSpeed;
		lastTime = 0;
	}
	
	public void setSpeed(float spd) {
		speed = spd;
	}
	
	public Matrix3D getTransform() {
		long millis = System.currentTimeMillis();
		lastTime += (millis - prevMillis) * speed;
		prevMillis = millis;
		return spline.getTransformation(lastTime);
	}
	
	private Spline spline;
	private long prevMillis;
	private float lastTime;
	private float speed;
}
